﻿using System;
using System.Windows.Forms;

namespace QuailRepositoryManager
{
    public partial class FormCodeGenerator : Form
    {
        public QuailRepoTestShell Shell
        {
            get; set;
        }

        public string Selector
        {
            get; set;
        }

        public FormCodeGenerator()
        {
            InitializeComponent();
        }

        private void FormCodeGenerator_Load(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Selector))
                Close();

            lblSelector.Text = Selector;
            UpdateCode();
        }

        public void UpdateCode()
        {
            /* var gen = new Generator(Shell.Page.GetControl(Selector).Tag, Selector)
                               {
                                   LazyLoad = chkLazy.Checked,
                                   Private = chkPrivate.Checked,
                                   Name = txtName.Text,
                               };

            txtCode.Text = gen.GetCode(); */
        }

        private void btnCopy_Click(object sender, EventArgs e)
        {
            Clipboard.SetDataObject(txtCode.Text, true);
        }

        private void txtName_Enter(object sender, EventArgs e)
        {
            txtName.SelectAll();
        }

        private void chkXCheckedChanged(object sender, EventArgs e)
        {
            UpdateCode();
        }

        private void txtName_Leave(object sender, EventArgs e)
        {
            UpdateCode();
        }
    }
}
